import unittest

import jsonschema

from api.ihrm_login_api import IhrmLoginApi


class Test_Ihrm_login(unittest.TestCase):
    def test01_login(self):
        json_data = {
            "mobile":"13800000002",
            "password":"123456"
        }

        resp =  IhrmLoginApi.test_login(json_data)
        print("登陆成功", resp.json())
        #

        self.assertEqual(200,resp.status_code)

        #使用全量字段校验、替换断言
        schema = {
            "type":"object",
            "properties":{
                "success":{"const":True},
                "code":{"const":10000},
                "message":{"pattern":"操作成功"},
                "data":{"type":"string"}
            },
            "required":["success","code","message","data"]

        }
        jsonschema.validate(instance = resp.json(),schema=schema )